home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Graphics / GraphicsWorkshop / Source / Converters / pcx.m < prev    next >
Encoding:
Text File  |  1993-01-15  |  1.6 KB  |  114 lines

  1. #import <stdio.h>
  2. #import <stdlib.h>
  3. #import <streams/streams.h>
  4. #import <appkit/graphics.h>
  5. #import <appkit/NXBitmapImageRep.h>
  6. #import "NXBitmapImageRepControl.h"
  7. #import "ImageControl.h"
  8. #import "pcx.h"
  9. #import "pcxlib.h"
  10.  
  11. @implementation PCX
  12.  
  13. - init
  14. {
  15.     return self;
  16. }
  17.  
  18. - free
  19. {
  20.     return [super free];
  21. }
  22.  
  23. - readFromStream: (NXStream *)stream from: sender;
  24. {
  25.     return pcxread(stream);
  26. }
  27.  
  28. - (BOOL)write: (id)image toStream: (NXStream *)stream from: sender;
  29. {
  30.     id                imageCon = [sender getImageControl: image];
  31.     unsigned char        *data, r[256], g[256], b[256];
  32.  
  33.     [imageCon convertToPalette:     256
  34.                 andReturn:        &data
  35.                 andPalettes:        r:g:b];
  36.     
  37.     pcxwrite(stream,
  38.             data, r, g, b,
  39.             [image pixelsWide],
  40.             [image pixelsHigh],
  41.             256);
  42.  
  43.     free(data);
  44.  
  45.     return YES;
  46. }
  47.  
  48. - readAllFromStream: (NXStream *)stream from: sender
  49. {
  50.     return nil;
  51. }
  52.  
  53. - (BOOL)writeAll: (id)image toStream: (NXStream *)stream
  54. {
  55.     return NO;
  56. }
  57.  
  58. - customSaveView: (int)width
  59. {
  60.     return nil;
  61. }
  62.  
  63. - customOpenView: (int)width
  64. {
  65.     return nil;
  66. }
  67.  
  68. - (char *)getFormatName
  69. {
  70.     return("PCX - A IBM/PC Picture Format");
  71. }
  72.  
  73.  - (BOOL)setCustomParameter: (const char *)parameter withValue: (void *)ptr
  74. {
  75.     return NO;
  76. }
  77.  
  78.  - (void *)getCustomParameter: (const char *)parameter
  79. {
  80.     return NULL;
  81. }
  82.  
  83. - (char *)copyrightNotice
  84. {
  85.     return "Original PCX Code\nCopyright (c) 1990 by Michael Davidson\n\nConverter Wrapper\nCopyright (c) 1993 by Alex Raftis.";
  86. }
  87.  
  88. - (int)errorState
  89. {
  90.     return CONVERT_ERR_NONE;
  91. }
  92.  
  93. - (int)errorMessage
  94. {
  95.     return ERROR_NO_ERROR;
  96. }
  97.  
  98. - (char *)errorStringMessage
  99. {
  100.     return NULL;
  101. }
  102.  
  103. - (BOOL)needsWindowServer;
  104. {
  105.     return NO;
  106. }
  107.  
  108. - (char *)protocolVersion
  109. {
  110.     return "1.0";
  111. }
  112.  
  113. @end
  114.